package com.junxonline.plat.dao.model;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.util.Date;
import java.util.List;

/**
 * @ClassName: Database
 * @Description: 数据库数据模型
 * @author JunX
 */

@Entity
@Table(name = "sys_database")
@JsonIgnoreProperties({"databaseTables"})
public class Database implements java.io.Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long databaseId;

    /**
     * 名称
     */
    @Column(nullable = false)
    private String databaseName;

    /**
     * 类型
     */
    @Column(nullable = false)
    private Integer databaseType;

    @Transient
    private String databaseTypeString;

    /**
     * 哈希值
     */
    @Column
    private String databaseHash;

    /**
     * 操作时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @Column(nullable = false)
    private Date databaseActionTime;

    /**
     * 日期分组
     */
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
    @Column(nullable = false)
    private Date databaseDate;

    /**
     * 操作人Id
     */
    @Column(nullable = false)
    private Long createUserId;

    @Transient
    @OneToMany(fetch = FetchType.LAZY, mappedBy="database")
    private List<DatabaseTable> databaseTables;

    public Database() {

    }

    public Long getDatabaseId() {
        return databaseId;
    }

    public void setDatabaseId(Long databaseId) {
        this.databaseId = databaseId;
    }

    public String getDatabaseName() {
        return databaseName;
    }

    public void setDatabaseName(String databaseName) {
        this.databaseName = databaseName;
    }

    public Integer getDatabaseType() {
        return databaseType;
    }

    public void setDatabaseType(Integer databaseType) {
        this.databaseType = databaseType;
    }

    public String getDatabaseTypeString() {
        return databaseTypeString;
    }

    public void setDatabaseTypeString(String databaseTypeString) {
        this.databaseTypeString = databaseTypeString;
    }

    public String getDatabaseHash() {
        return databaseHash;
    }

    public void setDatabaseHash(String databaseHash) {
        this.databaseHash = databaseHash;
    }

    public Date getDatabaseActionTime() {
        return databaseActionTime;
    }

    public void setDatabaseActionTime(Date databaseActionTime) {
        this.databaseActionTime = databaseActionTime;
    }

    public Date getDatabaseDate() {
        return databaseDate;
    }

    public void setDatabaseDate(Date databaseDate) {
        this.databaseDate = databaseDate;
    }

    public Long getCreateUserId() {
        return createUserId;
    }

    public void setCreateUserId(Long createUserId) {
        this.createUserId = createUserId;
    }

    public List<DatabaseTable> getDatabaseTables() {
        return databaseTables;
    }

    public void setDatabaseTables(List<DatabaseTable> databaseTables) {
        this.databaseTables = databaseTables;
    }
}
